package student.aistar.day14.enums;

import java.io.Serializable;

/**
 * 类里面使用枚举属性
 */
public class User implements Serializable {
    private Integer id;
    private String name;

    //性别 - 如果状态性的属性使用了字符串
    //User user = new User(1, "tom", "难"); //不能限定你这个状态是一个合法的参数
    //private String gender;

    //枚举类型也是属于对象类型
    //gender设置值的类型应该就是枚举类型
    //语法 - 枚举常量都是该枚举的具体的实例
    //可以将枚举常量设置给gender变量
    private Gender gender;

    public User() {
    }

    public User(Integer id, String name, Gender gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("User{");
        sb.append("id=").append(id);
        sb.append(", name='").append(name).append('\'');
//        sb.append(", gender=").append(gender);
        sb.append(", gender=").append(gender.getSign());
        sb.append('}');
        return sb.toString();
    }
}
